<template>
    <div class="search-input-container">
        <input id="searchInput"
               ref="input"
               autocomplete="off"
               v-model.trim="sharedSearchState.query"
               @keydown.esc="cancel"
               @change="change"
               type="text" :placeholder="placeHolder"/>
        <i class="icon-ion-ios-search"></i>
        <button  v-if="showAddButton" @click="showCreateConversationModal">
            <span style="position:relative;" class="iconfont icon-ic_user"></span>
        </button>
        <button  v-else @click="showCreateConversationModal">
            取消
        </button>
    </div>
</template>

<script>
import store from "../../../store";
export default {
    name: "SearchView",
    props: {
        value: {
            type: String,
            default: '',
        },
        showList:{

        }
    },
    data() {
        return {
            sharedSearchState: store.state.search,
            showAddButton:true,
        };
    },
    mounted(){
    },
    methods: {
        showCreateConversationModal() {
            this.showAddButton = !this.showAddButton
        },
        cancel() {
            this.$refs['input'].blur();
        },
        change(e){
		    this.$emit('input', e.target.value)
	    }
    },

    computed: {
        placeHolder() {
            return '搜索'
        }
    },

    watch: {
        
    }
}
</script>

<style lang="css" scoped>
.search-input-container {
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fafafa;
    -webkit-app-region: drag;
    position: relative;
    z-index: 1;
}

.search-input-container input {
    height: 25px;
    margin-left: 10px;
    margin-right: 10px;
    padding: 0 10px 0 20px;
    text-align: left;
    /* flex: 1; */
    /* 兼容Firefox 52 */
    width: 199px;
    border: 1px solid #e5e5e5;
    border-radius: 3px;
    outline: none;
    background-color: #eeeeee;
}

.search-input-container input:active {
    border: 1px solid #4168e0;
}

.search-input-container input:focus {
    border: 1px solid #4168e0;
}

.search-input-container i {
    position: absolute;
    left: 15px;
    /* 兼容Firefox 52 */
    top: 50%;
    transform: translate(0, -50%);
}

.search-input-container button {
    padding: 0 3px;
    font-size: 10px;
    height: 25px;
    margin-right: 10px;
    background-color: #fafafa;
    border-radius: 3px;
    border: 1px solid #e5e5e5;
}

.search-input-container button:active {
    background-color: #e5e5e5;
}

</style>
